<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html" charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui" />
    <meta name="format-detection" content="telephone=no">
    <title>实名认证</title>
    <script src="{{ asset('/admin/layui/layui.all.js') }}"></script>
    <link rel="stylesheet" href="{{asset('/admin/layui/css/layui.css') }}" />
    <link rel="stylesheet" href="{{asset('/api/static/css/base.css')}}">
    <link rel="stylesheet" href="{{asset('/api/static/css/autonym.css')}}">


    <script>
        (function (doc, win) {
            var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function () {
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    docEl.style.fontSize = 100 * (clientWidth / 1080) + 'px';
                };
            recalc();
            if (!doc.addEventListener) return;
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener('DOMContentLoaded', recalc, false);
        })(document, window);
    </script>
</head>
<body>
<div class="autonym">   <!-- 实名认证 -->
    <p class="pageTips">根据国家相关规定，请填写您的真实信息</p>
    <form class="form-horizontal">
        {{csrf_field()}}
        <ul>
            <li class="clearfix"><label class="fl">证件类型</label><div class="fl"><input type="text" value="身份证" readonly/></div></li>
            <li class="clearfix"><label class="fl">真实姓名</label><div class="fl"><input type="text" name="name" value="" maxlength="18" placeholder="输入真实姓名"/></div></li>
            <input name="uid"  type="hidden" value="{{$uid}}">

            <li class="clearfix"><label class="fl">证件号码</label><div class="fl"><input class="card" name="num" type="text" value="" maxlength="18" placeholder="输入证件号码"/></div></li>
            <li class="clearfix">
                <label class="fl">证件照片</label>
                <div class="fl">
                    <div class="positive uploadBox">
                        <a href="javascript:void(0);" id="positive"></a>
                        <input class="zhengmian" name="img1"  type="hidden">
                        <img src=""/>
                    </div>
                    <div class="backside uploadBox">
                        <a href="javascript:void(0);" id="backside"></a>
                        <input class="fanmian" name="img2" type="hidden">
                        <img src=""/>
                    </div>
                </div>
            </li>
        </ul>
        <div class="subBtn">
            <a href="javascript:void(0);" onclick="subAutonym()">提交认证</a>
        </div>
    </form>
</div>


</body>
<script src="{{asset('/api/static/js/jquery-1.10.2.min.js')}}"></script>
<script src="{{asset('/api/static/lib/moxie.min.js')}}"></script>
<script src="{{asset('/api/static/lib/plupload.full.min.js')}}"></script>
<script src="{{asset('/api/static/js/base.js')}}"></script>
<script>
    $(function() {
        var positiveImg = upload_Oss('positive');
        var backsideImg = upload_Oss('backside');
        $('.card').on('input propertychange', this, function(){
            var thisVal = $(this).val();
            if( thisVal.length<=17 ){
                $(this).val( onlyNum(thisVal) )
            }
        });
        $('.positive').change(function(){
            positiveImg.events.start()
            positiveImg.events.fn = function (pathArr) {
                $('.positive').find('img').show().attr('src', pathArr[pathArr.length-1])
                $('.positive').find('.zhengmian').val( pathArr[pathArr.length-1] )
                console.log($('.positive').find('.zhengmian').val())
            }
        });
        $('.backside').change(function(){
            backsideImg.events.start()
            backsideImg.events.fn = function (pathArr) {
                $('.backside').find('img').show().attr('src', pathArr[pathArr.length-1])
                $('.backside').find('.fanmian').val(pathArr[pathArr.length-1])
                console.log($('.backside').find('.fanmian').val())
            }
        });

    })
    function  subAutonym() {
        if( $("input[name='name']").val()=='' ){
            layer.msg('请输入您的真实姓名', {icon: 2});
            return
        }
        if( $("input[name='name']").val().length<2 ){
            layer.msg('请输入完整姓名', {icon: 2});
            return
        }
        if( !IdentityCodeValid( $("input[name='num']").val() ).type ){
            layer.msg( IdentityCodeValid( $("input[name='num']").val() ).tips, {icon: 2});
            return
        }
        if( $("input[name='img1']").val()=='' ){
            layer.msg('请上传身份证正面照片', {icon: 2});
            return
        }
        if( $("input[name='img2']").val()=='' ){
            layer.msg('请上传身份证反面照片', {icon: 2});
            return
        }
        $.ajax({
            url: '/api/autonym_submit',
            type: 'POST',
            data: $('form').serialize(),
            success: function(res){
                if(res.status == 1){
                    layer.msg('提交成功',{icon:1})
                    location.href= "/api/autonym_status?uid={{$uid}}"
                }else{
                    layer.msg(res.msg, {icon: 2});
                }
            }
        })
    }
</script>

</html>
